package com.sctvcloud.dongqu.ui.adapter.holder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ruihang.generalibrary.ui.util.IListData;
import com.sctvcloud.dongqu.R;
import com.sctvcloud.dongqu.beans.AddrInfo;
import com.sctvcloud.dongqu.ui.util.IListShowData;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Liuyu on 2018/8/16.
 */

public class AddressSelectHolder extends BaseAbsHolder<AddrInfo> {

    @BindView(R.id.item_addr_sele)
    protected ImageView ivSelect;
    @BindView(R.id.item_addr_user_name)
    protected TextView tvUserName;
    @BindView(R.id.item_addr_user_phone)
    protected TextView tvUserPhone;
    @BindView(R.id.item_addr_addr)
    protected TextView tvAddr;

    private boolean seletTemp;

    public AddressSelectHolder(Context context, View itemView) {
        super(context, itemView);
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                doInternalClick(v);
            }
        });
    }

    @Override
    protected void initInject() {
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(AddrInfo info) {
        tvAddr.setText(info.getAddress());
        tvUserName.setText(info.getReceiver());
        tvUserPhone.setText(info.getPhone());
        ivSelect.setImageResource(info.getStatus() == 1 ? R.mipmap.mine_control_selected_on : R.mipmap.mine_control_selected_off);
//        if (info.getStatus() == 1) {
//            seletTemp = true;
//        } else {
//            seletTemp = false;
//        }
    }

    @Override
    public void setData(AddrInfo info, int position, boolean isSelected) {
        super.setData(info, position, isSelected);
        if (isSelected != seletTemp) {
            seletTemp = isSelected;
        }
    }
}
